import java.util.Arrays;
import java.util.HashSet;

/**
 * @Author liangzai
 * @Description:
 */
public class Training {
    public static void main(String[] args) {
        HashSet<String> set = new HashSet<>();
        int[] arr = new int[3];
        int count = 0;
        for (int i = 1; i <= 1999; i++) {
            if(!cheak(i)) {
                continue;
            }
            for (int j = 1; j <= 1999-i && j!=i; j++) {
                if(!cheak(j)) {
                    continue;
                }
                int k = 2019 - i - j;
                if(k>0 && k!=i && k!=j) {
                    arr[0] = i;
                    arr[1] = j;
                    arr[2] = k;
                    Arrays.sort(arr);
                    if(set.add(Arrays.toString(arr))) {
                        count++;
                    }
                }

            }
        }
    }

    private static boolean cheak(int n) {
        while(n>0) {
            if(n%10==2 || n%10==4) {
                return false;
            }
            n /= 10;
        }
        return true;
    }
}
